home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2003-07-17 | 80.4 KB | 2,978 lines
// Copyright (C) 1997-2002 Alias|Wavefront, // a division of Silicon Graphics Limited. // // The information in this file is provided for the exclusive use of the // licensees of Alias|Wavefront. Such users have the right to use, modify, // and incorporate this code into other products for purposes authorized // by the Alias|Wavefront license agreement, without fee. // // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. // // // Alias|Wavefront Script File // MODIFY THIS AT YOUR OWN RISK // // ==================== expressionEditor.mel ========== // // SYNOPSIS // Create and show a text dialog for creating and editing // expressions // // CONTENTS // // PROCEDURES TO CREATE THE EXPRESSION EDITOR UI AND TOGGLE BETWEEN LAYOUTS. // These are in expressionEditor.mel // // EEmakeMenubar Make the menubar menus. // EEmakeFilterPopup Make filter popup menu. // EEcreateWin() Create the expression editor window // EEpostConfirm Post a confirm dialog. // EEswitchSelectLayout Switch between select-by-expr/obj modes. // EEswitchRulesForm Make visible/invisible rules form // // // EXPRESSION EDITOR QUERY PROCEDURES // These are in expressionEditor.mel // // EEgetCurrTypeList Get/return list of all objects of specified type. // EEgetExpressionList Get/return list of all expressions in the scene. // EEgetAttrFromNode Get the attribute from the node, if it's there. // EEgetEditorMessage Return a message re WINEDITOR. // EEisValidNodeName Is user-typed node name valid? // EEexprNameExists Does user-typed expression node name exist? // EEcheckValidExprName Is user-typed expression node name valid? // EEnodeIsInList Is the node in the current node list? // EEattrIsInList Is the attribute in the current attribute list? // // EXPRESSION EDITOR UI EDIT AND LIST MANAGEMENT PROCEDURES: // These are in expressionEditor.mel // // EEsetCreateMode Set the editor to create mode. // EEsetEditMode Set the editor to edit mode. // EEclearAllControls Clear name textfields and menus. // EEresetFilterToAll Set object filter to dag or dependency nodes. // EEresetExpressionName Reset the expression name textfield // EEresetNodeControls Reset controls for a new selected node. // EErebuildNodeList Rebuild the node selection list. // EErebuildAttrList Rebuild the attribute list. // EEupdateExprList Update the list of expressions. // EEaddNodeToList Add a node to the node list. // EEremoveNodeFromList Remove a node from the node list. // EEselectNodeInList Select a node in the node list. // EEnewSelectedNode Make the node selected and load its attrlist. // EEnewSelectedAttr Load a new attribute into the editor. // EEloadNewNodeAttr Load a new new node and its expression. // EEdisplayAttrExpr Display the expression of the current attribute. // EEdisplayNoExpression Reset controls when attr has no expression. // // EEregisterExpressions Register expressions to get expr changed msgs. // // // CORE PROCEDURES // These are in expressionEditor.mel // // EEupdateWindow Update the window at creation/show time. // expressionEditor() Create or display the expression editor (main) // // PROCEDURES TO HANDLE ONLY REGULAR EXPRESSIONS // These are all in expressions.mel // // EEexpressionCmd Print the expression command just issued. // EEapplyExpression Create or edit the expression // EErestoreExpression Restore the current expression from the node. // EEobjectListChanged User selected a non-particle obj in the node list. // EEexpressionListChanged User selected a new expression in the node list. // EEdisplayExpression Display an expression. // // PROCEDURES TO HANDLE ONLY PARTICLE EXPRESSION // These are all in dynExpressions.mel // // EEdynExpressionCmd Print the expression command just issued. // EEapplyParticleExpression Create or edit the particle expression // EErestoreParticleExpression Restore curr particle expression from node. // EEparticleListChanged User selected a particle in the node list. // EEdisplayParticleExpression Display a particle expression. // EEisParticle Is the node a particle? // EEisDynExpression Is the particle expression a dynExpression? // EEisValidDynAttr Is the particle attribute a valid one to show? // EEgetParticleExpression Get the p. expression from the particle // EEonlyLaunchParticleEditor Launch a text editor for a particle expression. // // EXPRESSION EDITOR UI CONTROL CALLBACKS: // These are all in expressionEdCallbacks.mel // // EEapplyCB Create/Edit the expression. // EEdeleteCB Delete the expression. // EErestoreCB Restore the expression. // EEclearCB Clear the text area. // EEcloseCB Close the window. // EEanimatedCB Callback for animated checkbox. // EEunitConversionCB Callback for unit conversion radio group. // EEexprNameTextCB Callback for expression name textfield. // EEdefaultNodeCB Callback for default node name textfield. // EEselectedNodeAttrCB Callback for node-attribute name textfield. // EEnewExpressionCB Callback for "New Expression" Button. // EEnodeListCB User selected something (sngl click) in node list. // EEnodeListDblClickCB User selected something (dbl click) in node list // EEattrListCB User selected something (sngl click)in attr list. // EEattrListDblClickCB User selected something (dbl click) in attr list. // EEselectFilterCB User selected something in the Select menu. // EEobjFilterCB User selected something in the Obj Filter menu. // EEattrFilterCB User selected something in the Attr Filter menu. // EEeditorCB User selected something in editors opt menu. // EErulesCB User selected a rules radio button. // // EXPRESSION EDITOR MESSAGE CALLBACKS // These are in expressionEdCallbacks.mel // These are called from TexprEdListenAction.cc // // EEactiveListChanged Callback for active list changed. // EEnodeAdded Callback for a node added to a scene. // EEnodeRemoved Callback for a node removed from the scene. // EEparticleExpressionCreated Callback for particle expression created. // EEparticleExpressionDeleted Callback for particle expression deleted. // EEexpressionCreated Callback for expression created. // EEexpressionEdited Callback for expression edited. // EEparticleExpressionEdited Callback for particle expression edited. // EEnodeNameChanged Callback for a node name change in the scene. // EEattributeAdded Callback for attribute added to selected node. // EEattributeRemoved Callback for attribute removed from selected node. // // EXPRESSION EDITOR TEXT EDITOR AND FAM HANDLING ROUTINES // These are in expressionEdTextEditor.mel // // EEdoLaunch Do the launch of the user's text editor of choice. // EElaunchEditor Launch a text editor for a regular expression. // EElaunchParticleEditor Launch a text editor for a particle expression // EEgetFileExpression Callback from TexprEdFamAction.cc when the user // writes text editor file to disk. Read file. // EEupdateParticleFileExpression Update a particle expression from a text editor file. // EEupdateFileExpression Update a regular expression from a text editor file. // EEdeleteStringElement Delete an element from a string array. // EEdeleteIntElement Delete an element from an int array. // EEdeleteEditorFile Callback from TexprEdFamAction.cc when user // dismisses a text editor. Delete the file. // // ****************************************************************** // // EXPRESSION EDITOR GLOBAL VARIABLES // // ****************************************************************** // global int $EEcreateMode = 1; // 1 = creating; 0 = editing // Some of these globals are needed, because if in text editor mode, // the controls cannot be queried, since the Expression Editor window // won't be created when calling up the Expression Editor from the // Attribute Editor or Channel Editor. // global int $EEobjIsParticle = 0; global int $EEisRuntime = 1; global int $EEcurrentEditor = 1; global int $EEdoLaunchTextEd = 0; global string $EEcurrExpressionName; global string $EEorigExpressionName; global int $EEeditedInEditor = 0; global string $EEcurrSelectedNode; // Currently active menu/filter modes. // global string $EEnodeMode = "object"; global string $EEcurrNodeFilter = "allSelected"; global string $EEcurrAttrFilter = "all"; // List of all files in text editors that are editing a particle expression. // global string $EEcurrParticleFiles[]; // Index into EEcurrFiles and EEcurrParticleFiles of the file whose // expression is currently being displayed in the expression editor. // global int $EEpExpressionInEditor = -1; global int $EEexpressionInEditor = -1; global int $EEfilesLoaded = 0; global int $EEfilesLoaded = 0; // begin} Math Functions ---- Count 28 global string $EEMathFunction[] = { "abs()", "float abs(float) / int abs(int) / vector abs(vector)", "acos()", "float acos(float number)", "acosd()", "float acosd(float number)", "asin()", "float asin(float number)", "asind()", "float asind(float number)", "atan()", "float atan(float number)", "atand()", "float atand(float number)", "atan2()", "float atan2(float Y, float X)", "atan2d()", "float atan2d(float Y, float X)", "clamp()", "float clamp(float min, float max, float parameter)", "ceil()", "float ceil(float number)", "cos()", "float cos(float number)", "cosd()", "float cosd(float number)", "exp()", "float exp(float number)", "floor()", "float floor(float number)", "hypot()", "float hypot(float x, float y)", "log()", "float log(float number)", "log10()", "float log10(float number)", "min()", "float min(float number, float number)", "max()", "float max(float number, float number)", "pow()", "float pow(float base, float exponent)", "sign()", "float sign(float number)", "sin()", "float sin(float number)", "sind()", "float sind(float number)", "sqrt()", "float sqrt(float number)", "tan()", "float tan(float number)", "tand()", "float tand(float number)", "trunc()", "float trunc(float number)" }; // end} Math Functions ---- // begin} Vector Functions ---- Count 6 global string $EEVectorFunction[] = { "angle()", "float angle(vector vector1, vector vector2)", "cross()", "vector cross(vector vector1, vector vector2)", "dot()", "float dot(vector vector1, vector vector2)", "mag()", "float mag(vector)", "rot()", "vector rot(vector point, vector axis, float angle)", "unit()", "vector unit(vector)" }; // end} Vector Functions ---- // begin} Conversion Functions ---- Count 4 global string $EEConversionFunction[] = { "deg_to_rad()", "float deg_to_rad(float degrees)", "rad_to_deg()", "float rad_to_deg(float radians)", "hsv_to_rgb()", "vector hsv_to_rgb(vector hsv)", "rgb_to_hsv()", "vector rgb_to_hsv(vector rgb)" }; // end} Conversion Functions ---- // begin} Random Number Functions ---- Count 6 global string $EERandomFunction[] = { "gauss()", "float gauss(float) / vector gauss(float, float) / vector gauss(vector)", "noise()", "float noise(float) / float noise(float, float) / float noise(vector)", "dnoise()", "vector dnoise(vector)", "rand()", "float rand(float [,float]) / vector rand(vector [,vector])", "sphrand()", "vector sphrand(float) / vector sphrand(vector)", "seed()", "int seed(int)" }; // end} Random Number Functions ---- // begin} Array Functions ---- Count 3 global string $EEArrayFunction[] = { "clear()", "int clear(array)", "size()", "int size(array) / int size(string)", "sort()", "array sort(array)" }; // end} Array Functions ---- // begin} Curve Functions ---- Count 3 // This block has distinct elements for the menu label // (the first string in each set) // and the literal string to insert in the expression (the second) // in order to distinguish between the 2 overloaded versions of hermite(). global string $EECurveFunction[] = { "linstep()", "linstep()", "float linstep(float start, float end, float parameter)", "smoothstep()", "smoothstep()", "float smoothstep(float start, float end, float parameter)", "hermite() (vector)", "hermite()", "vector hermite(vector start, vector end, vector tan1, vector tan2, float parameter)", "hermite() (scalar)", "hermite()", "float hermite(float start, float end, float tan1, float tan2, float parameter)" }; // end} Curve Functions ---- // ****************************************************************** // // EXPRESSION EDITOR UI CREATION PROCEDURES // // ****************************************************************** // ================ EEmakeMenubar ================ // // SYNOPSIS // Make the menus for the expression editor. // global proc EEmakeMenubar() { global string $EEnodeMode; global string $EEcurrNodeFilter; global string $EEcurrAttrFilter; menu -l "Select Filter" -familyImage "menuIconSelectFilter.xpm"; radioMenuItemCollection; menuItem -l "By Expression Name" -rb ($EEnodeMode == "expression") -c ("EEselectFilterCB expression") EEexprModeMenuItem; menuItem -l "By Object/Attribute Name" -rb ($EEnodeMode == "object") -c ("EEselectFilterCB object") EEobjModeMenuItem; menuItem -l "By Script Node Name" -rb ($EEnodeMode == "scriptNode") -c ("EEselectFilterCB scriptNode") EEscriptNodeModeMenuItem; setParent -m ..; menu -l "Object Filter" -familyImage "menuIconObjectFilter.xpm" EEobjFilterMenu; radioMenuItemCollection; menuItem -l "Selected Objects" -rb ($EEcurrNodeFilter == "allSelected") -c ("EEobjFilterCB allSelected") EEallSelectedMenuItem; menuItem -l "Dag Objects" -rb ($EEcurrNodeFilter == "dagObjects") -c ("EEobjFilterCB dagObjects") EEdagObjMenuItem; menuItem -l "Geometry Objects" -rb ($EEcurrNodeFilter == "geometry") -c ("EEobjFilterCB geometry"); menuItem -l "Transforms" -rb ($EEcurrNodeFilter == "transforms") -c ("EEobjFilterCB transforms"); menuItem -l "Dependency Nodes" -rb ($EEcurrNodeFilter == "depNodes") -c ("EEobjFilterCB depNodes") EEdepNodeMenuItem; menuItem -l "Lights" -rb ($EEcurrNodeFilter == "lights") -c ("EEobjFilterCB lights"); menuItem -l "Cameras" -rb ($EEcurrNodeFilter == "cameras") -c ("EEobjFilterCB cameras"); menuItem -l "Shaders" -rb ($EEcurrNodeFilter == "shaders") -c ("EEobjFilterCB shaders"); if (`isTrue "DynamicsUIExists"`) { menuItem -l "Dynamics" -subMenu true; menuItem -l "Particles" -rb ($EEcurrNodeFilter == "particles") -c ("EEobjFilterCB particles"); menuItem -l "Emitters" -rb ($EEcurrNodeFilter == "emitters") -c ("EEobjFilterCB emitters"); menuItem -l "Springs" -rb ($EEcurrNodeFilter == "springs") -c ("EEobjFilterCB springs"); menuItem -l "Gravity Fields" -rb ($EEcurrNodeFilter == "gravity") -c ("EEobjFilterCB gravity"); menuItem -l "Drag Fields" -rb ($EEcurrNodeFilter == "drag") -c ("EEobjFilterCB drag"); menuItem -l "Air Fields" -rb ($EEcurrNodeFilter == "air") -c ("EEobjFilterCB air"); menuItem -l "Newton Fields" -rb ($EEcurrNodeFilter == "newton") -c ("EEobjFilterCB newton"); menuItem -l "Radial Fields" -rb ($EEcurrNodeFilter == "radial") -c ("EEobjFilterCB radial"); menuItem -l "Turbulence Fields" -rb ($EEcurrNodeFilter == "turbulence") -c ("EEobjFilterCB turbulence"); menuItem -l "Uniform Fields" -rb ($EEcurrNodeFilter == "uniform") -c ("EEobjFilterCB uniform"); menuItem -l "Vortex Fields" -rb ($EEcurrNodeFilter == "vortex") -c ("EEobjFilterCB vortex"); menuItem -l "Rigid Bodies" -rb ($EEcurrNodeFilter == "rigidBody") -c ("EEobjFilterCB rigidBody"); menuItem -l "Rigid Constraints" -rb ($EEcurrNodeFilter == "rigidConstraint") -c ("EEobjFilterCB constraint"); setParent -menu ..; } if (`isTrue "KinematicsExists"`) { menuItem -l "Kinematics" -subMenu true; menuItem -l "Joints" -rb ($EEcurrNodeFilter == "joint") -c ("EEobjFilterCB joints"); menuItem -l "Handles" -rb ($EEcurrNodeFilter == "handle") -c ("EEobjFilterCB handles"); menuItem -l "IK Systems" -rb ($EEcurrNodeFilter == "ikSystem") -c ("EEobjFilterCB ikSystems"); menuItem -l "IK Solvers" -rb ($EEcurrNodeFilter == "ikSolver") -c ("EEobjFilterCB ikSolvers"); setParent -menu ..; } if (`isTrue "DeformersExists"`) { menuItem -l "Deformers" -subMenu true; menuItem -l "Joint Lattice" -rb ($EEcurrNodeFilter == "jointLattice") -c ("EEobjFilterCB jointLattice"); menuItem -l "Blend Shape" -rb ($EEcurrNodeFilter == "blendShape") -c ("EEobjFilterCB blendShape"); menuItem -l "Bone Lattice" -rb ($EEcurrNodeFilter == "boneLattice") -c ("EEobjFilterCB boneLattice"); menuItem -l "Cluster" -rb ($EEcurrNodeFilter == "cluster") -c ("EEobjFilterCB cluster"); menuItem -l "Lattice" -rb ($EEcurrNodeFilter == "lattice") -c ("EEobjFilterCB lattice"); menuItem -l "Sculpt" -rb ($EEcurrNodeFilter == "sculpt") -c ("EEobjFilterCB sculpt"); menuItem -l "Wire" -rb ($EEcurrNodeFilter == "wire") -c ("EEobjFilterCB wire"); setParent -menu ..; } setParent -m ..; menu -l "Attribute Filter" -familyImage "menuIconAttributeFilter.xpm" EEattrFilterMenu; radioMenuItemCollection; menuItem -l "All " -rb ($EEcurrAttrFilter == "all") -c ("EEattrFilterCB all") EEallAttrsMenuItem; menuItem -l "Connected to Expressions" -rb ($EEcurrAttrFilter == "expr") -c ("EEattrFilterCB expr") EEselAttrsMenuItem; setParent -m ..; global string $EEMathFunction[]; global string $EEVectorFunction[]; global string $EERandomFunction[]; global string $EEConversionFunction[]; global string $EEArrayFunction[]; global string $EECurveFunction[]; int $i = 0, $limit; menu -l "Insert Functions" EEInsertFuncMenu; // Math Functions // menuItem -l "Math Functions" -sm true EEmathMI; $limit = size($EEMathFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEMathFunction[$i] -c ("EEmathFuncCB " + $i) -ann $EEMathFunction[$i+1]; } setParent -menu ..; // Random Functions // menuItem -l "Random Functions" -sm true EErandMI; $limit = size($EERandomFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EERandomFunction[$i] -c ("EErandFuncCB " + $i) -ann $EERandomFunction[$i+1]; } setParent -menu ..; // Vector Functions // menuItem -l "Vector Functions" -sm true EEvectMI; $limit = size($EEVectorFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEVectorFunction[$i] -c ("EEvectFuncCB " + $i) -ann $EEVectorFunction[$i+1]; } setParent -menu ..; // Conversion Functions // menuItem -l "Conversion Functions" -sm true EEconvMI; $limit = size($EEConversionFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEConversionFunction[$i] -c ("EEconvFuncCB " + $i) -ann $EEConversionFunction[$i+1]; } setParent -menu ..; // Array Functions // menuItem -l "Array Functions" -sm true EEarrayMI; $limit = size($EEArrayFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEArrayFunction[$i] -c ("EEarrayFuncCB " + $i) -ann $EEArrayFunction[$i+1]; } setParent -menu ..; // Curve Functions // This block has distinct elements for the menu label // (the first string in each set) // and the literal string to insert in the expression (the second) // in order to distinguish between the 2 overloaded // versions of hermite(). // menuItem -l "Curve Functions" -sm true EEcurveMI; $limit = size($EECurveFunction); for ($i = 0; $i < $limit; $i+=3) { menuItem -l $EECurveFunction[$i] -c ("EEcurveFuncCB " + $i) -ann $EECurveFunction[$i+2]; } setParent -menu ..; setParent -menu ..; menu -l "Help" -helpMenu true EEhelpMenuItem; menuItem -label "Help on Expression Editor..." -enableCommandRepeat false -command "showHelp ExpressionEditor"; setParent -m ..; } // EEmakeMenubar // ================ EEmakeFilterPopup ================ // // SYNOPSIS // Make the popup menu for the object filter. // global proc EEmakeFilterPopup() { popupMenu EEnodePOP; menuItem -l "Select Filter" -sm true EEselectFilterPopMenu; menuItem -l "By expression name" -c ("EEselectFilterCB expression"); menuItem -l "By object/attribute name" -c ("EEselectFilterCB object") ; menuItem -l "By Script Node Name" -c ("EEselectFilterCB scriptNode"); setParent -m ..; menuItem -l "Object Filter" -sm true EEobjFilterPopMenu; menuItem -l "Selected Objects" -c ("EEobjFilterCB allSelected"); menuItem -l "Dag Objects" -c ("EEobjFilterCB dagObjects"); menuItem -l "Geometry Objects" -c ("EEobjFilterCB geometry"); menuItem -l "Transforms" -c ("EEobjFilterCB transforms"); menuItem -l "Dependency Nodes" -c ("EEobjFilterCB depNodes"); menuItem -l "Lights" -c ("EEobjFilterCB lights"); menuItem -l "Cameras" -c ("EEobjFilterCB cameras"); menuItem -l "Shaders" -c ("EEobjFilterCB shaders"); if (`isTrue "DynamicsUIExists"`) { menuItem -l "Dynamics" -subMenu true; menuItem -l "Particles" -c ("EEobjFilterCB particles"); menuItem -l "Emitters" -c ("EEobjFilterCB emitters"); menuItem -l "Springs" -c ("EEobjFilterCB springs"); menuItem -l "Gravity Fields" -c ("EEobjFilterCB gravity"); menuItem -l "Drag Fields" -c ("EEobjFilterCB drag"); menuItem -l "Air Fields" -c ("EEobjFilterCB air"); menuItem -l "Newton Fields" -c ("EEobjFilterCB newton"); menuItem -l "Radial Fields" -c ("EEobjFilterCB radial"); menuItem -l "Turbulence Fields" -c ("EEobjFilterCB turbulence"); menuItem -l "Uniform Fields" -c ("EEobjFilterCB uniform"); menuItem -l "Vortex Fields" -c ("EEobjFilterCB vortex"); menuItem -l "Rigid Bodies" -c ("EEobjFilterCB rigidBody"); menuItem -l "Rigid Constraints" -c ("EEobjFilterCB constraint"); setParent -menu ..; } if (`isTrue "KinematicsExists"`) { menuItem -l "Kinematics" -subMenu true; menuItem -l "Joints" -c ("EEobjFilterCB joints"); menuItem -l "Handles" -c ("EEobjFilterCB handles"); menuItem -l "IK Systems" -c ("EEobjFilterCB ikSystems"); menuItem -l "IK Solvers" -c ("EEobjFilterCB ikSolvers"); setParent -menu ..; } if (`isTrue "DeformersExists"`) { menuItem -l "Deformers" -subMenu true; menuItem -l "Joint Lattice" -c ("EEobjFilterCB jointLattice"); menuItem -l "Blend Shape" -c ("EEobjFilterCB blendShape"); menuItem -l "Bone Lattice" -c ("EEobjFilterCB boneLattice"); menuItem -l "Cluster" -c ("EEobjFilterCB cluster"); menuItem -l "Lattice" -c ("EEobjFilterCB lattice"); menuItem -l "Sculpt" -c ("EEobjFilterCB sculpt"); menuItem -l "Wire" -c ("EEobjFilterCB wire"); setParent -menu ..; } setParent -m ..; menuItem -l "Attribute Filter" -sm true EEattrFilterPopMenu; menuItem -l "All" -c ("EEattrFilterCB all"); menuItem -l "Connected to Expressions" -c ("EEattrFilterCB expr"); setParent -m ..; global string $EEMathFunction[]; global string $EEVectorFunction[]; global string $EERandomFunction[]; global string $EEConversionFunction[]; global string $EEArrayFunction[]; global string $EECurveFunction[]; int $i = 0, $limit; menuItem -l "Insert Functions" -sm true EEInsertFuncPopMenu; // Math Functions // menuItem -l "Math Functions" -sm true; $limit = size($EEMathFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEMathFunction[$i] -c ("EEmathFuncCB " + $i) -ann $EEMathFunction[$i+1]; } setParent -menu ..; // Random Functions // menuItem -l "Random Functions" -sm true; $limit = size($EERandomFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EERandomFunction[$i] -c ("EErandFuncCB " + $i) -ann $EERandomFunction[$i+1]; } setParent -menu ..; // Vector Functions // menuItem -l "Vector Functions" -sm true; $limit = size($EEVectorFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEVectorFunction[$i] -c ("EEvectFuncCB " + $i) -ann $EEVectorFunction[$i+1]; } setParent -menu ..; // Conversion Functions // menuItem -l "Conversion Functions" -sm true; $limit = size($EEConversionFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEConversionFunction[$i] -c ("EEconvFuncCB " + $i) -ann $EEConversionFunction[$i+1]; } setParent -menu ..; // Array Functions // menuItem -l "Array Functions" -sm true; $limit = size($EEArrayFunction); for ($i = 0; $i < $limit; $i+=2) { menuItem -l $EEArrayFunction[$i] -c ("EEarrayFuncCB " + $i) -ann $EEArrayFunction[$i+1]; } setParent -menu ..; // Curve Functions // This block has distinct elements for the menu label // (the first string in each set) // and the literal string to insert in the expression (the second) // in order to distinguish between the 2 overloaded // versions of hermite(). // menuItem -l "Curve Functions" -sm true; $limit = size($EECurveFunction); for ($i = 0; $i < $limit; $i+=3) { menuItem -l $EECurveFunction[$i] -c ("EEcurveFuncCB " + $i) -ann $EECurveFunction[$i+2]; } setParent -menu ..; setParent -menu ..; } // EEmakeFilterPopup // // ================ EEcreateWin ================ // // SYNOPSIS // Create the expression editor window and its layout, // and register the callbacks. // global proc EEcreateWin(string $winName) { global int $EEcurrentEditor; global int $EEisRuntime; // Create a new dialog and base container (mainForm). // int $wndHeight = 540; // adjust the window height // so that all the controls get displayed correctly if(`about -mac`) $wndHeight = 600; window -t "Expression Editor" -in "Expressions" -ip -mb true -w 460 -h $wndHeight -rtf false $winName; EEmakeMenubar(); frameLayout -bv false -cll false -lv false -mh 2 EEmainFrame; formLayout -nd 100 EEmainForm; // Create the popup menu for the filters // EEmakeFilterPopup(); // Create the Selection layout // formLayout -nd 100 EEselectionForm; // Attach the selection form to the main form // formLayout -e -af EEselectionForm right 0 -af EEselectionForm left 0 -af EEselectionForm top 0 EEmainForm; columnLayout -adj true EEselectionCL; text -al "center" -l "Creating Expression" EEceModeT; // Create the expression name form and textfield. Use text and // textField instead of textFieldGrp, in order to line the label // and textfield up on the left side. // formLayout -nd 100 EEexprNameForm; text -al "left" -l "Expression Name" EEexprNameLabel; textField -cc "EEexprNameTextCB" -w 200 EEexprNameT; formLayout -e -af EEexprNameLabel "left" 0 -af EEexprNameLabel "top" 8 -ac EEexprNameT "left" 4 EEexprNameLabel -aoc EEexprNameT "top" 0 EEexprNameLabel EEexprNameForm; // Create the "New Expression" button. // button -l "New Expression" -c ("EEnewExpressionCB 1") -w 120 -h 28 -enable false EEnewExpButton; formLayout -e -ac EEnewExpButton left 4 EEexprNameT -aoc EEnewExpButton top 0 EEexprNameT EEexprNameForm; // Back up to EESelectionCL // setParent ..; // Make the selection frame -- the Node and Attributes Lists. // frameLayout -l "Selection" -lv true -bv true -cll true -bs "etchedIn" -cl false -mh 4 EEselectionF; // Create the selection scrolled lists // formLayout -nd 100 EEselectFiltForm; formLayout -nd 100 EEnodeForm; formLayout -e -af EEnodeForm left 0 -af EEnodeForm top 0 // -af EEnodeForm bottom 0 EEselectFiltForm; text -al "left" -l "Objects" EEselectNamesL; formLayout -e -af EEselectNamesL left 0 -af EEselectNamesL top 2 EEnodeForm; textScrollList -ams false -nr 6 -dcc "EEnodeListDblClickCB" -sc "EEnodeListCB" EEnodeList; // set the scroll list height, // so that the scroll bars appear properly if (`about -mac`) { int $EEnodeListHeight = 110; textScrollList -e -height $EEnodeListHeight EEnodeList; } formLayout -e -af EEnodeList left 0 -af EEnodeList right 0 -af EEnodeList bottom 0 -ac EEnodeList top 2 EEselectNamesL EEnodeForm; // Back up to EEselectFiltForm // setParent ..; // Make the attribute list // formLayout -nd 100 EEattrListForm; formLayout -e -af EEattrListForm top 0 -af EEattrListForm right 0 -ap EEnodeForm left 0 0 -ap EEnodeForm right 0 50 -ap EEattrListForm left 2 50 -ap EEattrListForm right 0 100 EEselectFiltForm; text -al "left" -l "Attributes" EEattrNamesL; formLayout -e -af EEattrNamesL left 0 -af EEattrNamesL top 2 EEattrListForm; textScrollList -ams false -nr 6 -sc "EEattrListCB" -dcc "EEattrListDblClickCB" EEattrList; // set the scroll list height, // so that the scroll bars appear properly if (`about -mac`) { int $EEattrListHeight = 110; textScrollList -e -height $EEattrListHeight EEattrList; } formLayout -e -af EEattrList left 0 -af EEattrList right 0 -af EEattrList bottom 0 -ac EEattrList top 2 EEattrNamesL EEattrListForm; setParent EEselectionCL; // Create two tabs, one for expressions and the other for // script nodes. tabLayout -tv false -innerMarginWidth 0 -innerMarginHeight 0 EEoptionsTab; columnLayout -adj true EEexprOptsCL; // Create the textfields for the selected and default nodes. // textFieldGrp -l "Selected Obj & Attr" -cc "EEselectedNodeAttrCB" EEselNameT; textFieldGrp -l "Default Object" -cc "EEdefaultNodeCB" EEdefNameT; checkBox -al "left" -l "Always Evaluate" -v true -cc "EEanimatedCB" EEanimCBox; radioButtonGrp -nrb 3 -l "Convert Units:" -l1 "All" -l2 "None" -l3 "Angular only" -cw 1 100 -cw 2 60 -cw 3 70 -cw 4 100 -sl 1 -on1 ("EEunitConversionCB all") -on2 ("EEunitConversionCB none") -on3 ("EEunitConversionCB angularOnly") EEunitsRBG; radioButtonGrp -nrb 2 -l "Particle:" -l1 "Runtime" -l2 "Creation" -cw 1 100 -cw 2 100 -cw 3 110 -on1 ("EErulesCB runtime") -on2 ("EErulesCB creation") EErulesRBG; if ($EEisRuntime) radioButtonGrp -e -sl 1 EErulesRBG; else radioButtonGrp -e -sl 2 EErulesRBG; setParent EEoptionsTab; // Create the UI for script nodes. // columnLayout -adj false EEscriptOptsCL; textFieldGrp -l "Selected Script Node" -cc "EEselectedScriptCB" EEselScriptNodeNameT; rowLayout -nc 2 -cw 1 110 -cal 1 "left" -cw 2 290 -cal 2 "left" -cat 1 "both" 0 -cat 2 "left" 10 EEscriptNodeTypeRowL; text -l "Execute On:" -align "right"; attrEnumOptionMenu -l "" -ei 0 "Demand" -ei 1 "Open/Close" -ei 2 "GUI Open/Close" -ei 3 "UI Configuration (Internal)" -ei 4 "Software Render" -ei 5 "Software Frame Render" -ei 6 "Scene Configuration (Internal)" EEscriptNodeTypeAOM; setParent ..; radioButtonGrp -nrb 2 -l "Script:" -l1 "Before" -l2 "After" -cw 1 100 -cw 2 100 -cw 3 110 -on1 ("EEbeforeAfterScriptCB") -on2 ("EEbeforeAfterScriptCB") -sl 1 EEscriptRBG; rowLayout -nc 2 -cw 1 50 -cal 1 "left" -cw 2 290 -cal 2 "left" -cat 1 "both" 0 -cat 2 "left" 10 EEeditorRowL; text -l ""; button -l "Test Script" -align "center" -w 100 -c "EEscriptNodeTestCB" EEscriptNodeTestButton; setParent ..; tabLayout -edit -sti 1 EEoptionsTab; setParent EEmainForm; // Create the form for the multi-line scrolled text widget. // formLayout -nd 100 EEtextForm; // Attach the text form to the main form on right and left. // formLayout -e -af EEtextForm right 0 -af EEtextForm left 0 -af EEtextForm bottom 0 EEmainForm; // Attach the top of the text form to the bottom of the // selection form. // formLayout -e -ac EEtextForm top 0 EEselectionForm EEmainForm; rowLayout -nc 2 -cw 1 50 -cal 1 "left" -cw 2 290 -cal 2 "left" -cat 1 "both" 0 -cat 2 "left" 10 EEeditorRowL; text -l "Editor:" -align "right"; // The evaluation version of Maya cannot launch external programs // so it cannot edit expressions with an external editor. // int $allowExtEdit = ! `about -evalVersion`; optionMenu -l "" -cc EEeditorCB EEeditorOM; menuItem -l "Expression Editor" EEexprEdItem; if (`about -nt`) { menuItem -en $allowExtEdit -l "Text Editor" EEotherItem; // change the default width so that it works with // either large or small fonts. int $w = `optionMenu -q -w EEeditorOM`; optionMenu -e -w (int($w*1.3)) EEeditorOM; } else if (`about -irix`) { menuItem -en $allowExtEdit -l "jot" EEjotItem; menuItem -en $allowExtEdit -l "vi" EEviItem; menuItem -en $allowExtEdit -l "vim" EEvimItem; menuItem -en $allowExtEdit -l "xemacs" EExemacsItem; menuItem -en $allowExtEdit -l "Other" EEotherItem; } else if (`about -linux`) { menuItem -en $allowExtEdit -l "emacs" EEemacsItem; menuItem -en $allowExtEdit -l "gvim" EEgvimItem; menuItem -en $allowExtEdit -l "vi" EEviItem; menuItem -en $allowExtEdit -l "vim" EEvimItem; menuItem -en $allowExtEdit -l "xedit" EExeditItem; menuItem -en $allowExtEdit -l "xemacs" EExemacsItem; menuItem -en $allowExtEdit -l "Other" EEotherItem; } if ( `optionVar -exists EEexprEdTextEditor` && $allowExtEdit ) $EEcurrentEditor = `optionVar -q EEexprEdTextEditor`; if ($EEcurrentEditor != 1) optionMenu -e -sl $EEcurrentEditor EEeditorOM; setParent ..; // Create the single-line text widget // for displaying the method signature. // textField -text "" -w 200 -editable false EEhelpField; // Create the multi-line scrolled text widget. // text -l "Expression:" EEtextLabel; string $path = `scrollField -ww false EEmultiText`; // Attach the textfield to the form. // formLayout -e -af EEeditorRowL top 0 -af EEeditorRowL left 0 -ac EEtextLabel top 4 EEeditorRowL -af EEtextLabel left 0 -ac EEmultiText top 4 EEtextLabel -af EEmultiText left 0 -af EEmultiText right 0 -af EEmultiText bottom 30 -ac EEhelpField top 4 EEmultiText -af EEhelpField left 0 -af EEhelpField right 0 -af EEhelpField bottom 0 EEtextForm; setParent ..; // Create the buttons at the bottom of the window. // // Create the form for the apply, update and clear buttons // formLayout -nd 100 EEbuttonsForm; // Attach the form to its parent, except on the top // formLayout -e -af EEbuttonsForm bottom 5 -af EEbuttonsForm left 0 -af EEbuttonsForm right 0 EEmainForm; // Attach the bottom of the text form to the top of the // buttons form // formLayout -e -ac EEtextForm bottom 5 EEbuttonsForm EEmainForm; // Lay out the buttons evenly across the form. // button -l "Create" -h 26 EEapplyButton; button -l "Delete" -h 26 -enable false EEdeleteButton; button -l "Reload" -h 26 -enable false EErestoreButton; button -l "Clear" -h 26 EEclearButton; button -l "Close" -h 26 EEcloseButton; formLayout -e -af EEapplyButton left 5 -ap EEapplyButton right 3 20 -ap EEdeleteButton left 2 20 -ap EEdeleteButton right 3 40 -ap EErestoreButton left 2 40 -ap EErestoreButton right 3 60 -ap EEclearButton left 2 60 -ap EEclearButton right 3 80 -ap EEcloseButton left 2 80 -af EEcloseButton right 5 EEbuttonsForm; setParent ..; setParent ..; if (`about -mac`) { setParent ..; setParent ..; } // Register the callbacks // button -e -c "EEapplyCB" EEapplyButton; button -e -c "EEdeleteCB" EEdeleteButton; button -e -c "EErestoreCB" EErestoreButton; button -e -c "EEclearCB" EEclearButton; button -e -c "EEcloseCB" EEcloseButton; } // EEcreateWin // ================ EEpostConfirm ================ // // SYNOPSIS // Post a confirm dialog with theMessage. // global proc EEpostConfirm(string $theMessage) { confirmDialog -t "Warning" -ma "left" -m $theMessage -b "Close" -cb "Close"; } // EEpostConfirm // ================ EEswitchSelectLayout ================ // // SYNOPSIS // Called when the Select Filter menu is changed. // global proc EEswitchSelectLayout(string $whichMethod) { global string $EEnodeMode; if ($EEnodeMode == "scriptNode" || $whichMethod == "scriptNode") { textField -e -tx "" EEexprNameT; } $EEnodeMode = $whichMethod; if ($whichMethod == "expression") { text -e -l "Expression Name" EEexprNameLabel; button -e -l "New Expression" EEnewExpButton; text -e -l "Expressions" EEselectNamesL; text -e -enable false EEattrNamesL; // Disable the filters menu and Selected Attribute textfield // menu -e -enable false EEobjFilterMenu; menu -e -enable false EEattrFilterMenu; menu -e -enable false EEobjFilterPopMenu; menu -e -enable false EEattrFilterPopMenu; textFieldGrp -e -tx "" EEselNameT; textFieldGrp -e -enable false EEselNameT; text -e -l "Expression:" EEtextLabel; tabLayout -e -sti 1 EEoptionsTab; } else if ($whichMethod == "object") { text -e -l "Expression Name" EEexprNameLabel; button -e -l "New Expression" EEnewExpButton; text -e -l "Objects" EEselectNamesL; text -e -enable true EEattrNamesL; // Enable the filter menus and Selected Attribute textfield // menu -e -enable true EEobjFilterMenu; menu -e -enable true EEattrFilterMenu; menu -e -enable true EEobjFilterPopMenu; menu -e -enable true EEattrFilterPopMenu; textFieldGrp -e -enable true EEselNameT; text -e -l "Expression:" EEtextLabel; tabLayout -e -sti 1 EEoptionsTab; } else { // Set the Editor for script nodes. // text -e -l "Script Node Name" EEexprNameLabel; button -e -l "New Script Node" EEnewExpButton; text -e -l "Script Nodes" EEselectNamesL; text -e -enable false EEattrNamesL; menu -e -enable false EEobjFilterMenu; menu -e -enable false EEattrFilterMenu; menu -e -enable false EEobjFilterPopMenu; menu -e -enable false EEattrFilterPopMenu; textFieldGrp -e -tx "" EEselNameT; textFieldGrp -e -enable false EEselNameT; textFieldGrp -e -enable true EEselScriptNodeNameT; text -e -l "Script:" EEtextLabel; tabLayout -e -sti 2 EEoptionsTab; } } // EEswitchSelectLayout // ================ EEswitchRulesForm ================ // // SYNOPSIS // Enable/disable some controls when switching between // particle and non-particle objects. // global proc EEswitchRulesForm(int $enable) { if ($enable) { radioButtonGrp -e -enable true EErulesRBG; radioButtonGrp -e -enable false EEunitsRBG; checkBox -e -enable false EEanimCBox; } else { radioButtonGrp -e -enable false EErulesRBG; radioButtonGrp -e -enable true EEunitsRBG; checkBox -e -enable true EEanimCBox; } } // ***************************************************************** // // EXPRESSION EDITOR QUERY PROCEDURES // // ****************************************************************** // ================ EEgetCurrTypeList ================ // // SYNOPSIS // Get and return thelist of all objects in the scene // of the specified type. // global proc string[] EEgetCurrTypeList(string $currType) { string $nodeList[]; switch($currType) { case "allSelected": $nodeList = `ls -sl`; break; case "dagObjects": $nodeList = `ls -dag`; break; case "geometry": $nodeList = `ls -geometry`; break; case "transforms": $nodeList = `ls -transforms`; break; case "lights": $nodeList = `ls -lights`; break; case "cameras": $nodeList = `ls -cameras`; break; case "shaders": $nodeList = `ls -materials`; break; case "depNodes": $nodeList = `ls -dep`; break; case "joints": $nodeList = `ls -type joint`; break; case "handles": $nodeList = `ls -type ikHandle`; break; case "ikSystems": $nodeList = `ls -type ikSystem`; break; case "ikSolvers": $nodeList = `ls -type ikSolver`; break; case "jointLattice":$nodeList = `ls -type jointLattice`; break; case "blendShape": $nodeList = `ls -type blendShape`; break; case "boneLattice": $nodeList = `ls -type boneLattice`; break; case "cluster": $nodeList = `ls -type cluster`; break; case "lattice": $nodeList = `ls -type ffd`; break; case "sculpt": $nodeList = `ls -type sculpt`; break; case "wire": $nodeList = `ls -type wire`; break; case "scriptNode": $nodeList = `ls -type script`; break; } if (`isTrue "DynamicsUIExists"`) { switch($currType) { case "particles": $nodeList = `ls -type particle`; break; case "emitters": $nodeList = `ls -type pointEmitter`; break; case "springs": $nodeList = `ls -type spring`; break; case "gravity": $nodeList = `ls -type gravityField`; break; case "drag": $nodeList = `ls -type dragField`; break; case "air": $nodeList = `ls -type airField`; break; case "newton": $nodeList = `ls -type newtonField`; break; case "radial": $nodeList = `ls -type radialField`; break; case "turbulence": $nodeList = `ls -type turbulenceField`; break; case "uniform": $nodeList = `ls -type uniformField`; break; case "vortex": $nodeList = `ls -type vortexField`; break; case "rigidBody": $nodeList = `ls -type rigidBody`; break; case "constraint": $nodeList = `ls -type rigidConstraint`; break; } } return $nodeList; } // EEgetCurrTypeList // ================ EEgetExpressionList ================ // // // SYNOPSIS // Get and return the list of all expressions in the scene. // global proc string[] EEgetExpressionList() { string $nodeList[]; string $exprList[]; // Get all the expression nodes. // $nodeList = `ls -type expression`; // Get all the particles that own expressions. // if (`isTrue "DynamicsUIExists"`) { string $particles[] = `ls -type particle`; string $attrs[]; string $expr; int $pi, $ai, $exprCount = 0; for($pi = 0; $pi < size($particles); $pi++) { // // During file import AND referencing, Maya is put into // a new namespace, and the file is read into that space, // and all references to an object by name are considered // relative to that namespace. It can be thought of as // a directory structure. The "ls" command, however, always // returns the names relative to the global or root namespace. // Therefore, if we try to access them using those names, and // we are not in that global namespace, then we get "Object // not found" errors. To get around this, we prepend ":" to // the names from "ls". This tells Maya that this name is // to be considered relative to the global namespace. // It is only needed here, since it is only relavent to NEW // nodes nodes, and only this particle expression code actually // tries to use the names. // string $fullNamespaceName = (":"+$particles[$pi]); $expr = `dynExpression -q -r $fullNamespaceName`; if (size($expr) == 0) { $expr = `dynExpression -q -c $fullNamespaceName`; } if (size($expr) > 0) { $exprList[$exprCount] = $particles[$pi]; $exprCount++; } } int $ei, $ni; for ($ei = 0, $ni = size($nodeList); $ei < size($exprList); $ei++, $ni++) { $nodeList[$ni] = $exprList[$ei]; } } return $nodeList; } // EEgetExpressionList // ================ EEgetAttrFromNode ================ // // SYNOPSIS // // Find out if the current selected object has the // specified attribute. If so, add it the the attributes // scrolled list, and return its index; if not, return -1. // global proc int EEgetAttrFromNode(string $attrName) { global int $EEobjIsParticle; int $i, $found; int $attrIndex = -1; string $attrs[], $attrsShort[]; string $selectedObj[] = `textScrollList -q -si EEnodeList`; // First look in the list of attribute long and short names. // $attrs = `listAttr -s -v -c -u -m $selectedObj[0]`; $attrsShort = `listAttr -sn -s -v -c -u -m $selectedObj[0]`; $found = 0; for ($i = 0; $i < size($attrs); $i++) { if ($attrs[$i] == $attrName || $attrsShort[$i] == $attrName) { $found = 1; // Make sure the long name is the one put in the attr list. // $attrName = $attrs[$i]; break; } } // If not found, and if it's a particle, look in the list of array // attributes, long and short names. // if (!$found && $EEobjIsParticle) { clear($attrs); clear($attrsShort); $attrs = `listAttr -a -v -c -u -m $selectedObj[0]`; $attrsShort = `listAttr -sn -a -v -c -u -m $selectedObj[0]`; for ($i = 0; $i < size($attrs); $i++) { if ($attrs[$i] == $attrName || $attrsShort[$i] == $attrName) { $found = 1; // Make sure the long name is the one put in the attr list. // $attrName = $attrs[$i]; break; } } } // If the user typed a valid attribute name, put it in the // current attributes list and return the index (1-based). // if ($found) { textScrollList -e -a $attrName EEattrList; $attrIndex = `textScrollList -q -ni EEattrList`; } clear($attrs); clear($attrsShort); clear($selectedObj); return $attrIndex; } // EEgetAttrFromNode // ================ EEgetEditorMessage ================ // // SYNOPSIS // Return message re WINEDITOR. Called by editorCB if the user // chooses "Other" in the option menu. // global proc string EEgetEditorMessage() { return ("Set your own editor with preferred flags by setting the\nenvironment variable \"WINEDITOR\", if it is not already set.\nYou can set it at the command window or through the SGI\nDesktop menu --DeskTop/Desktop/Default Editor.\nWarning: the editor must be set to run in the foreground.\n"); } // ================ EEisValidNodeName ================ // // SYNOPSIS // Make sure the node name sent in is valid. // global proc int EEisValidNodeName(string $nodeName) { string $result[] = `ls $nodeName`; int $status = 1; if (size($result) == 0) { warning ("Expression Editor: "+$nodeName+" is not a valid object name"); $status = 0; } else if (size($result) > 1) { warning ("Expression Editor: more than one object matches the name: "+$nodeName); $status = 0; } clear($result); return $status; } // EEisValidNodeName // ================ EEexprNameExists ================ // // SYNOPSIS // Return if the name is of an existing expression // global proc int EEexprNameExists(string $exprName) { string $allExprNames[] = EEgetExpressionList(); int $i, $numExpressions; $numExpressions = size($allExprNames); int $nameExists = 0; for ($i = 0; $i < $numExpressions; $i++) { if ($allExprNames[$i] == $exprName) { $nameExists = 1; break; } } clear($allExprNames); return $nameExists; } // ================ EEcheckValidExprName ================ // // SYNOPSIS // Make sure the expression name sent in is valid. // global proc int EEcheckValidExprName(string $exprName) { global string $EEcurrExpressionName; int $nameValid = 1; string $exprName = `textField -q -tx EEexprNameT`; // The user can only name a new expression or change the // name of an expression being edited; so if the name // the user typed is already the name of an expression node // then it is not valid, so remove it and restore the // previous name. // int $nameExists = EEexprNameExists($exprName); if ($nameExists) { $nameValid = 0; warning ("Expression Editor: name "+$exprName+" is already used. Restoring previous name."); // Name already exists, so is not valid to reuse, so restore the // previous name, or blank the field if there was no name. // if (size($EEcurrExpressionName) > 0) textField -e -tx $EEcurrExpressionName EEexprNameT; else textField -e -tx "" EEexprNameT; } return $nameValid; } // EEcheckValidExprName // ================ EEnodeIsInList ================ // // SYNOPSIS // Return the index of the node in the scrolled list. // or -1 if it's not there. // global proc int EEnodeIsInList(string $nodeName) { // If there is no object list, return "Not found". // if (`textScrollList -q -ni EEnodeList` == 0) { return -1; } // Get the list of object names. // string $listObjs[] = `textScrollList -q -ai EEnodeList`; int $currentObjSize = size($listObjs); int $objIndex = -1; int $i; for ($i = 0; $i < $currentObjSize; $i++) { if ($nodeName == $listObjs[$i]) { // Found it; return the position in the list // $objIndex = $i; break; } } clear($listObjs); return $objIndex; } // EEnodeIsInList // ================ EEattrIsInList ================ // // SYNOPSIS // // Return the index of the attribute in the scrolled list. // or -1 if it's not there. // global proc int EEattrIsInList(string $attrName) { global int $EEobjIsParticle; string $listAttrsShort[]; int $i; // If there is no attribute list, return "Not found". // if (`textScrollList -q -ni EEattrList` == 0) return -1; // Will need to test short and long name, so get the selected // object name to get the short list; but get the long list from // the attribute list. It was made using the same listAttr // call, without -sn. // string $selectedObj[] = `textScrollList -q -si EEnodeList`; string $listAttrs[] = `textScrollList -q -ai EEattrList`; $listAttrsShort = `listAttr -sn -s -v -c -u -m -k $selectedObj[0]`; // If the object is a particle, we also want to get the array // attributes. // if ($EEobjIsParticle) { string $arrayAttrsShort[]; int $attrSize; $arrayAttrsShort = `listAttr -sn -a -v -c -u -m $selectedObj[0]`; $attrSize = size($arrayAttrsShort); $listAttrSize = size($listAttrsShort); for ($i = 0; $i < $attrSize; $i++) { $listAttrsShort[$listAttrSize] = $arrayAttrsShort[$i]; $listAttrSize++; } } $listAttrSize = size($listAttrs); int $attrIndex = -1; for ($i = 0; $i < $listAttrSize; $i++) { if (($attrName == $listAttrs[$i]) || ($attrName == $listAttrsShort[$i])) { // Found it; return the position in the list (the // list is 1-based) // $attrIndex = $i + 1; break; } } clear($selectedObj); clear($listAttrs); clear($listAttrsShort); return $attrIndex; } // EEattrIsInList // ***************************************************************** // // EXPRESSION EDITOR UI EDIT AND LIST MANAGEMENT PROCEDURES // // ****************************************************************** // ================ EEsetCreateMode ================ // // SYNOPSIS // Set the editor state to create mode. // global proc EEsetCreateMode(string $createMessage) { global int $EEcreateMode; global string $EEnodeMode; $EEcreateMode = 1; text -e -l $createMessage EEceModeT; button -e -l "Create" -w 100 -h 26 EEapplyButton; button -e -enable false EEdeleteButton; button -e -enable false EErestoreButton; if ($EEnodeMode == "scriptNode") { // ScriptNodes: This control can not be queried. To eliminate any // confusion, this control is disabled during creation. // attrEnumOptionMenu -e -enable false EEscriptNodeTypeAOM; } } // EEsetCreateMode // ================ EEsetEditMode ================ // // SYNOPSIS // Set the editor state to edit mode. // global proc EEsetEditMode(string $editMessage) { global int $EEcreateMode; global string $EEnodeMode; $EEcreateMode = 0; text -e -l $editMessage EEceModeT; button -e -enable true EErestoreButton; button -e -l "Edit" -w 100 -h 26 EEapplyButton; button -e -enable true EEdeleteButton; if ($EEnodeMode == "scriptNode") { // ScriptNodes: This control can not be queried. To eliminate any // confusion, this control is disabled during creation. // attrEnumOptionMenu -e -enable true EEscriptNodeTypeAOM; } } // EEsetEditMode // ================ EEclearAllControls ================ // // SYNOPSIS // Clear all the expression, node, attribute names/lists // global proc EEclearAllControls() { global int $EEobjIsParticle; global int $EEpExpressionInEditor; global int $EEexpressionInEditor ; global string $EEcurrExpressionName; global string $EEorigExpressionName; global string $EEnodeMode; // Only clear the expression name if it exists, as otherwise the // user may have typed a new name to use it for the future. // Before clearing it, unregister the expression if it is registered. // string $exprName = `textField -q -tx EEexprNameT`; if (EEisParticle($exprName) || size($exprName) && (EEexprNameExists($exprName) || EEscriptNameExists($exprName))) { EEresetExpressionName(""); } textFieldGrp -e -tx "" EEselNameT; textFieldGrp -e -tx "" EEdefNameT; scrollField -e -tx "" EEmultiText; checkBox -e -v 1 EEanimCBox; radioButtonGrp -e -sl 1 EEunitsRBG; if ($EEnodeMode != "scriptNode") { if ($EEobjIsParticle) EEsetCreateMode("Creating Particle Expression"); else EEsetCreateMode("Creating Expression"); } else { EEsetCreateMode("Creating Script Node"); } $EEcurrExpressionName = ""; $EEorigExpressionName = ""; // Nothing in editor means no expressions in files are // currently in the editor. // $EEpExpressionInEditor = -1; $EEexpressionInEditor = -1; // Some script node controls textFieldGrp -e -tx "" EEselScriptNodeNameT; } // EEclearAllControls // ================ EEresetFilterToAll ================ // // SYNOPSIS // Reset the filter to "all dependency nodes" and rebuild // the object list // global proc EEresetFilterToAll(string $nodeName) { global string $EEcurrNodeFilter; global string $EEnodeMode; // Check and see if the object selected is in the dag list, // if so, reset to it, otherwise reset to dependency nodes. // string $nodeList[] = `ls -dag`; int $i; int $found = 0; if (size($nodeName) > 0) { for ($i = 0; $i < size($nodeList); $i++) { if ($nodeName == $nodeList[$i]) { $found = 1; break; } } } if ($found || size($nodeName) == 0) { $EEcurrNodeFilter = "dagObjects"; menuItem -e -rb true EEdagObjMenuItem; } else { $EEcurrNodeFilter = "depNodes"; menuItem -e -rb true EEdepNodeMenuItem; } $EEnodeMode = "object"; EErebuildNodeList("object"); } // EEresetFilterToAll // ================ EEresetNodeControls ================ // // SYNOPSIS // Reset controls for a new selected object. // global proc EEresetNodeControls(string $nodeName) { global int $EEobjIsParticle; global string $EEnodeMode; textFieldGrp -e -tx $nodeName -enable true EEselNameT; if (EEisParticle($nodeName)) { $EEobjIsParticle = 1; EEswitchRulesForm(1); textFieldGrp -e -tx "" -enable false EEdefNameT; text -e -enable false EEexprNameLabel; EEresetExpressionName(""); textField -e -enable false EEexprNameT; EEsetCreateMode("Creating Particle Expression"); } else { $EEobjIsParticle = 0; EEswitchRulesForm(0); text -e -enable true EEexprNameLabel; // Only clear the expression name if it exists, as otherwise the // user may have typed a new name to use it for the future. // string $exprName = `textField -q -tx EEexprNameT`; if ($EEnodeMode == "scriptNode") { textFieldGrp -e -tx "" -enable false EEdefNameT; if (size($exprName) && EEscriptNameExists($exprName)) { EEresetExpressionName(""); // textField -e -tx "" EEexprNameT; EEsetCreateMode("Creating Script Node"); } } else { textFieldGrp -e -tx $nodeName -enable true EEdefNameT; if (size($exprName) && EEexprNameExists($exprName)) { EEresetExpressionName(""); // textField -e -tx "" EEexprNameT; EEsetCreateMode("Creating Expression"); } } textField -e -enable true EEexprNameT; } if ($EEnodeMode == "scriptNode") { textFieldGrp -e -tx $nodeName -enable true EEselScriptNodeNameT; } else { // Load the name of the objects attributes into the editor's list. // textFieldGrp -e -tx $nodeName -enable true EEselNameT; EErebuildAttrList($nodeName); } } // EEresetNodeControls // ================ EErebuildNodeList ================ // // SYNOPSIS // Rebuild the list of objects for the expression editor // global proc EErebuildNodeList(string $whichList) { global string $EEcurrNodeFilter; global string $EEcurrSelectedNode; global string $EEorigExpressionName; global string $EEcurrExpressionName; global int $EEcreateMode; global int $EEobjIsParticle; int $i; string $nodeList[]; // First pick up the current and orig expression names, so we can // reinstate, if desired. // string $currExprName = `textField -q -tx EEexprNameT`; string $origExprName = $EEorigExpressionName; // Clear the old object and attribute lists. But first, make // sure messages have been stopped for them. // $nodeList = `textScrollList -q -ai EEnodeList`; for ($i = 0; $i < size($nodeList); $i++) { EEremoveNodeFromList($nodeList[$i], 1); } $EEcurrSelectedNode = ""; textScrollList -e -ra EEattrList; // Get the list of expression or objects of the selected type. // if ($whichList == "expression") $nodeList = EEgetExpressionList(); else if ($whichList == "scriptNode") $nodeList = EEgetCurrTypeList("scriptNode"); else $nodeList = EEgetCurrTypeList($EEcurrNodeFilter); if (size($nodeList) == 0) { EEclearAllControls(); return; } // Make the object list in the UI, and register to listen to // changes in each node. // string $newNode; string $prevNewNode; for ($i = 0; $i < size($nodeList); $i++) { string $buffer[]; tokenize($nodeList[$i], ".", $buffer); // If the buffer has more than two items in it, the first item // will be the node name and the others attribute names, // e.g. "cv". So, strip $nodeName to just the node name, // and the rest will go into the attr list. // if (size($buffer) >= 2 ) { $newNode = $buffer[0]; if ($newNode != $prevNewNode) { EEaddNodeToList($newNode); $prevNewNode = $newNode; } } else { EEaddNodeToList($nodeList[$i]); } } string $currObjAttrName; if ($whichList == "expression") { // If switching to expression mode, and an expression is // in the editor, make it the selected item in the list, // otherwise clear all controls. // // Get the name of the obj.attr the expression is connected to // if (size($currExprName) > 0 && !$EEcreateMode) { if ($EEobjIsParticle) { // Expression name and obj.attr name are the same for // particles. // $currObjAttrName = $currExprName; } else { string $objAttr[] = `listConnections -s false -d true -shapes true -plugs true -scn true $currExprName`; $currObjAttrName = $objAttr[0]; } EEselectNodeInList($currExprName); textFieldGrp -e -tx $currObjAttrName EEselNameT; $EEorigExpressionName = $origExprName; $EEcurrExpressionName = $currExprName; } else { EEclearAllControls(); } } else if ($whichList == "object") { // If switching to object/filter mode, and an object is in the // editor, if it's in the new list, make it the selected item // in the list, build its attribute list, and make the current // attribute selected. If it's not in the list, make the // first item in the new list selected and get its attribute list. // $currObjAttrName = `textFieldGrp -q -tx EEselNameT`; if (size($currObjAttrName) > 0) { string $buffer[]; tokenize($currObjAttrName, ".", $buffer); $currentObj = $buffer[0]; $currentAttr = $buffer[1]; if (EEnodeIsInList($currentObj) > -1) { EEnewSelectedNode($currentObj); if ((size($currentAttr) > 0) && (($attrListIndex = EEattrIsInList($currentAttr)) > -1)) { EEnewSelectedAttr($attrListIndex); } return; } } EEclearAllControls(); // Either there's no object name current or the current one // is not in the new list, so if there is an object list, make // the first item selected, build its attribute list, and set // the object name in the selected obj/attr textfield. // if (`textScrollList -q -ni EEnodeList` > 0) { textScrollList -e -sii 1 EEnodeList; string $theObj[] = `textScrollList -q -si EEnodeList`; EEnewSelectedNode($theObj[0]); } } else { // If switching to script node mode, and an object is in the // editor, if it's in the new list, make it the selected item // in the list. If it's not in the list, make the // first item in the new list selected and get its attribute list. // string $currNodeName = `textField -q -tx EEexprNameT`; if (size($currNodeName) > 0) { EEnewSelectedNode($currNodeName); if (!$EEcreateMode) { textFieldGrp -e -tx $currNodeName EEselScriptNodeNameT; $EEorigExpressionName = $origExprName; $EEcurrExpressionName = $currExprName; } } else { EEclearAllControls(); } } clear($nodeList); } // EErebuildNodeList // ================ EErebuildAttrList ================ // // SYNOPSIS // Rebuild the list of attributes for the expression editor // global proc EErebuildAttrList(string $nodeName) { global string $EEcurrAttrFilter; global int $EEobjIsParticle; int $i; // Get the object's attribute list; clear the current // attribute list from the attribute scroll list, and put // the new list in the control, and the object name in // the editor default object textfield. // string $objAttrs[] = `listAttr -s -v -c -u -m -k $nodeName`; if ($EEobjIsParticle) { string $arrayAttrs[]; int $attrSize; $arrayAttrs = `listAttr -a -v -c -u -m $nodeName`; $arrayAttrSize = size($arrayAttrs); $attrSize = size($objAttrs); for ($i = 0; $i < $arrayAttrSize; $i++) { $objAttrs[$attrSize] = $arrayAttrs[$i]; $attrSize++; } } textScrollList -e -ra EEattrList; if ($EEcurrAttrFilter == "all") { for ($i = 0; $i < size($objAttrs); $i++) { if (!$EEobjIsParticle || EEisValidDynAttr($objAttrs[$i])) textScrollList -e -a $objAttrs[$i] EEattrList; } } else { // List only attributes that have expressions. // Find out if there's an expression node connected to the // attribute, if there is one, add the attribute to the // list. // string $objAttrName; string $exprName[]; string $particleExpr; for ($i = 0; $i < size($objAttrs); $i++) { if (!$EEobjIsParticle) { $objAttrName = ($nodeName+"."+$objAttrs[$i]); $exprName = `listConnections -s true -d false -t "expression" -scn true $objAttrName`; if (size($exprName[0]) > 0) { textScrollList -e -a $objAttrs[$i] EEattrList; } } else { $particleExpr = `dynExpression -q -r $nodeName`; if (size($particleExpr) == 0) { $particleExpr = `dynExpression -q -c $nodeName`; } else if (size($particleExpr) > 0) { textScrollList -e -a $objAttrs[$i] EEattrList; } } } } } // EErebuildAttrList // // ================ EEupdateExprList ================ // // SYNOPSIS // Update the expression list when a name has changed. // global proc EEupdateExprList() { global string $EEorigExpressionName; global string $EEcurrExpressionName; global string $EEnodeMode; // If the user has changed the expression name, and is in // select-by-expression mode, update the list with the new // name. // if ($EEorigExpressionName != $EEcurrExpressionName) { if ($EEnodeMode == "expression" || $EEnodeMode == "scriptNode") { EEremoveNodeFromList($EEorigExpressionName, 0); EEaddNodeToList($EEcurrExpressionName); // Select the node. // EEselectNodeInList($EEcurrExpressionName); } $EEorigExpressionName = $EEcurrExpressionName; } } // EEupdateExprList // ================ EEaddNodeToList ================ // // SYNOPSIS // // Add a node to the expression/object list, if it's not already // there. // global proc EEaddNodeToList(string $nodeName) { // Listen for changes in the node, then add it. // expressionEditorListen -ln $nodeName; if (EEnodeIsInList($nodeName) == -1) textScrollList -e -a $nodeName EEnodeList; } // EEaddNodeToList // ================ EEremoveNodeFromList ================ // // SYNOPSIS // // Remove a node from the expression/object list. // global proc EEremoveNodeFromList(string $nodeName, int $removeExpr) { global string $EEorigExpressionName; global string $EEcurrExpressionName; global string $EEcurrSelectedNode; // Stop listening for changes in the node, then remove it. // expressionEditorListen -sln $nodeName; string $selected[] = `textScrollList -q -si EEnodeList`; if (size($selected) > 0 && $nodeName == $selected[0]) { expressionEditorListen -sla $nodeName; // If the flag says to, remove the // expression from the expression field. // if ($removeExpr) { EEresetExpressionName(""); $EEcurrExpressionName = ""; $EEorigExpressionName = ""; $EEcurrSelectedNode = ""; } } if (EEnodeIsInList($nodeName) > -1) textScrollList -e -ri $nodeName EEnodeList; } // EEremoveNodeFromList // ================ EEselectNodeInList ================ // // SYNOPSIS // // Select a node in the expression/object list. // global proc EEselectNodeInList(string $nodeName) { global string $EEcurrSelectedNode; global string $EEnodeMode; // Stop listening for attribute changes in the current selected // selected object; select the new node and set it up to // listen for attribute changes. // if (size($EEcurrSelectedNode) > 0) { expressionEditorListen -sla $EEcurrSelectedNode; } textScrollList -e -si $nodeName EEnodeList; // If in expression mode, then the selected node is an // expression, so also should go in the expression name // field. // if ($EEnodeMode == "expression" || $EEnodeMode == "scriptNode") textField -e -tx $nodeName EEexprNameT; $EEcurrSelectedNode = $nodeName; expressionEditorListen -la $nodeName; } // EEselectNodeInList // // ================ EEnewSelectedNode ================ // // SYNOPSIS // Make the object selected, and load its // attribute list into the editor's attribute list. // global proc EEnewSelectedNode(string $nodeName) { int $EEobjIsParticle; EEclearAllControls(); EEresetNodeControls($nodeName); // Show the object selected, and register it to get attribute // added/removed messages. // EEselectNodeInList($nodeName); // If the new node is a particle, get its expression, if it has // one. // if (EEisParticle($nodeName)) { string $particleExpr = EEgetParticleExpression($nodeName, ""); if (size($particleExpr) == 0) EEdisplayNoExpression($nodeName); else EEdisplayParticleExpression($nodeName, $particleExpr); } } // EEnewSelectedNode // ================ EEnewSelectedAttr ================ // // SYNOPSIS // Load a new attribute from the attribute list into the editor. // global proc EEnewSelectedAttr(int $attrIndex) { // Get the selected object // string $selectedObj[] = `textScrollList -q -si EEnodeList`; // Make the attribute selected and put the object.attribute // name in the selected object/attribute textfield; // textScrollList -e -sii $attrIndex EEattrList; textScrollList -e -shi $attrIndex EEattrList; // Make sure we have the long name of the attribute. // string $names[] = `textScrollList -q -si EEattrList`; string $attrName = $names[0]; EEloadNewNodeAttr($selectedObj[0], $attrName); } // EEnewSelectedAttr // ================ EEloadNewNodeAttr ================ // // SYNOPSIS // // Load a new object.attribute and its expression into // the editor. // global proc EEloadNewNodeAttr(string $nodeName, string $attrName) { global int $EEobjIsParticle; string $objAttrName; $objAttrName = ($nodeName+"."+$attrName); // Display the expression for this attribute, if there is one. // EEdisplayAttrExpr($objAttrName); textFieldGrp -e -tx $objAttrName EEselNameT; // User may have sent in a short name, so find the attribute in the list // checking both short and long names, then select it. // if (($attrListIndex = EEattrIsInList($attrName)) > -1) { textScrollList -e -sii $attrListIndex EEattrList; textScrollList -e -shi $attrListIndex EEattrList; } } // EEloadNewNodeAttr // ================ EEdisplayAttrExpr ================ // // SYNOPSIS // Display the expression connected to the current // object.attribute in the scrolled textfield, and // put the name in the expression name textfield. // global proc EEdisplayAttrExpr(string $objAttrName) { global int $EEobjIsParticle; if (!$EEobjIsParticle) { string $exprName[] = `listConnections -s true -d false -t "expression" -scn true $objAttrName`; // If the obj.attr has an expression, load it; otherwise // clear and reset the controls. // if (size($exprName[0]) == 0) EEdisplayNoExpression($objAttrName); else EEdisplayExpression($exprName[0]); clear($exprName); } else { string $particleExpr; string $buffer[]; tokenize($objAttrName, ".", $buffer); $particleExpr = EEgetParticleExpression($buffer[0], $buffer[1]); if (size($particleExpr) == 0) { EEdisplayNoExpression($objAttrName); EEswitchRulesForm(1); } else { if (EEisDynExpression($objAttrName)) { EEdisplayParticleExpression($buffer[0], $particleExpr); EEswitchRulesForm(1); } else { string $exprName[] = `listConnections -s true -d false -t "expression" -scn true $objAttrName`; EEdisplayExpression($exprName[0]); EEswitchRulesForm(0); } } } } // EEdisplayAttrExpr // ================ EEdisplayNoExpression ================ // // SYNOPSIS // Set the controls for no expression. // // global proc EEdisplayNoExpression(string $objAttrName) { global int $EEcurrentEditor; global int $EEdoLaunchTextEd; global string $EEcurrExpressionName; global string $EEorigExpressionName; global int $EEobjIsParticle; global int $EEexpressionInEditor; global int $EEpExpressionInEditor; global string $EEnodeMode; // Only clear the expression name if it exists or is a particle // name, as otherwise the user may have typed a new name to use it // for the future. // string $exprName = `textField -q -tx EEexprNameT`; int $isParticle = EEisParticle($exprName); if ( (size($exprName)) && ($isParticle || EEexprNameExists($exprName))) { // First, unregister the current expression, if it is // eligible. // EEresetExpressionName(""); } if ($EEnodeMode == "scriptNode") { EEresetExpressionName(""); } scrollField -e -tx "" EEmultiText; radioButtonGrp -e -sl 1 EEunitsRBG; string $buffer[]; tokenize($objAttrName, ".", $buffer); if ($EEobjIsParticle) { EEsetCreateMode("Creating Particle Expression"); if ($EEcurrentEditor != 1 && $EEdoLaunchTextEd) { EElaunchParticleEditor("", $buffer[0]); scrollField -e -enable false EEmultiText; } textFieldGrp -e -tx "" -enable false EEdefNameT; // For a particle , the expression name must be the name of the // particle, so put it in the expression name textfield now. // EEresetExpressionName($buffer[0]); // textField -e -tx $buffer[0] EEexprNameT; } else { if ($EEnodeMode == "scriptNode") { textFieldGrp -e -tx "" -enable false EEdefNameT; EEsetCreateMode("Creating Script Node"); } else { EEsetCreateMode("Creating Expression"); // Set default to current obj // textFieldGrp -e -tx $buffer[0] EEdefNameT; checkBox -e -v true EEanimCBox; } if ($EEcurrentEditor != 1 && $EEdoLaunchTextEd) { EElaunchEditor($objAttrName, "", ""); scrollField -e -enable false EEmultiText; } else { scrollField -e -enable true EEmultiText; } } if ($EEnodeMode == "scriptNode") { textFieldGrp -e -tx "" EEselScriptNodeNameT; } else { textFieldGrp -e -tx $objAttrName EEselNameT; } if (!$EEdoLaunchTextEd) { $EEexpressionInEditor = -1; $EEpExpressionInEditor = -1; } $EEdoLaunchTextEd = 0; $EEcurrExpressionName = ""; $EEorigExpressionName = ""; } // EEdisplayNoExpression // ================ EEregisterExpressions ================ // // SYNOPSIS // Register all expressions in the scene to receive // expression changed messages. // // global proc EEregisterExpressions() { int $i; string $expressions[] = `ls -type expression`; for ($i = 0; $i < size($expressions); $i++) { expressionEditorListen -le $expressions[$i]; } clear($expressions); if (`isTrue "DynamicsUIExists"`) { $expressions = `ls -type particle`; for ($i = 0; $i < size($expressions); $i++) { expressionEditorListen -le $expressions[$i]; } } clear($expressions); } // ****************************************************************** // // EXPRESSION EDITOR CORE PROCEDURES // // ****************************************************************** // ================ EEupdateWindow ================ // // SYNOPSIS // Update the Expression Editor -- called when the Editor is // created or shown. The expression to be put in the // window is that connected to nodeName.attrName // // global proc EEupdateWindow(string $nodeName, string $attrName) { global string $EEcurrNodeFilter; global string $EEnodeMode; string $buffer[]; // If an object name has been sent in, set the editor // to object mode and selected mode. // if (size($nodeName) > 0) { if (EEisScriptNode($nodeName)) { $EEnodeMode = "scriptNode"; } else { $EEnodeMode = "object"; $EEcurrNodeFilter = "allSelected"; menuItem -e -rb true EEallSelectedMenuItem; } } if ($EEnodeMode == "scriptNode") { EEswitchSelectLayout("scriptNode"); } if ($EEnodeMode == "object") { button -e -enable false EEnewExpButton; } else { button -e -enable true EEnewExpButton; } // Rebuild the object list. // EErebuildNodeList($EEnodeMode); // If an object name was sent in, load it. // if (size($nodeName) > 0) { // If it is not in the list, add it and make it the // selected one; and get its attribute list. // if (EEnodeIsInList($nodeName) == -1) { EEaddNodeToList($nodeName); EEnewSelectedNode($nodeName); if ($EEnodeMode != "scriptNode") { // Load nodeName's attribute list. // if (size($attrName) > 0) { int $attrListIndex; if (($attrListIndex = EEattrIsInList($attrName)) == -1) { // If the attribute name as been sent in, put it in the list // and select it even if it is not an attribute we don't usually // put in the list, e.g. it is not keyable. // textScrollList -e -a $attrName EEattrList; $attrListIndex = `textScrollList -q -ni EEattrList`; } EEnewSelectedAttr($attrListIndex); } } } else { // If the node is in the list, load it and the specified // attribute, if there is one. // // But first, if an attribute name is sent in and is not in the // attr list, add it. // EEnewSelectedNode($nodeName); if (size($attrName) > 0) { int $attrListIndex; if (($attrListIndex = EEattrIsInList($attrName)) == -1) { textScrollList -e -a $attrName EEattrList; $attrListIndex = `textScrollList -q -ni EEattrList`; } EEnewSelectedAttr($attrListIndex); } } } EEregisterExpressions(); } // EEupdateWindow // ================ expressionEditor ================ // // SYNOPSIS // Create and show an expression editor text dialog. // // global proc expressionEditor(string $particleMode, string $nodeName, string $attrName) { global int $EEcurrentEditor; global int $EEisRuntime; global int $EEfilesLoaded; if (!$EEfilesLoaded) { source expressions.mel; source dynExpressions.mel; source expressionEdCallbacks.mel; source expressionEdTextEditor.mel; source scriptNodes.mel; $EEfilesLoaded = 1; } // Check that nodeName exists and attrName is valid. // if (size($nodeName) > 0) { if (!`objExists $nodeName`) { warning("ExpressionEditor: " + $nodeName + " does not exist."); $nodeName = ""; $attrName = ""; } } else { // If there is no nodeName, make sure attrName is also blank. // $attrName = ""; } if (size($nodeName) > 0 && size($attrName) > 0) { // If attrName is not an attribute for nodeName, don't use it. // if (size(`ls ($nodeName + "." + $attrName)`) == 0) { warning("ExpressionEditor: " + $attrName + " does not exist for object " + $nodeName + "."); $attrName = ""; } else { if (size($particleMode) == 0) { // If the attribute cannot be set in an expression, don't // put it in the editor. // string $attrs[] = `listAttr -scalar -multi -string $attrName $nodeName`; if (size($attrs) == 0) { warning("ExpressionEditor: " + $attrName + " can not be modified by an expression."); $attrName = ""; } } } } string $EEWin = "expressionEditorWin"; int $callListen = 0; if ($particleMode == "runtime") $EEisRuntime = 1; else if ($particleMode == "creation") $EEisRuntime = 0; if ( `optionVar -exists EEexprEdTextEditor` ) $EEcurrentEditor = `optionVar -q EEexprEdTextEditor`; if (size($nodeName) > 0 && size($attrName) > 0 && $EEcurrentEditor != 1) { if (EEisParticle($nodeName)) { // Find out if the attribute is connected to a TdnExpression. // If it is, treat it like a non-particle attribute. // string $objAttr = $nodeName + "." + $attrName; if (EEisDynExpression($objAttr)) EEonlyLaunchParticleEditor($nodeName, $attrName); else EEonlyLaunchEditor($nodeName, $attrName); } else if (EEisScriptNode($nodeName)) { EEonlyLaunchScriptEditor($nodeName, $attrName); } else { EEonlyLaunchEditor($nodeName, $attrName); } return; } if (! `window -exists $EEWin`) { EEcreateWin($EEWin); $callListen = 1; } EEupdateWindow($nodeName, $attrName); if ($EEisRuntime) radioButtonGrp -e -sl 1 EErulesRBG; else radioButtonGrp -e -sl 2 EErulesRBG; if ($callListen) expressionEditorListen(); // Open/display the editor. // showWindow $EEWin; } // expressionEditor